/**
 * 代理模式
 */

class RealImg {
    constructor(fileName) {
        this.fileName = fileName
        this.loadFromDisk()
    }

    display() {
        console.log('display... ' + this.fileName);
    }

    loadFromDisk() {
        console.log('load from disk... ' + this.fileName);
    }
}

class ProxyImg {
    constructor(fileName) {
        this.readImg = new RealImg(fileName)
    }

    display() {
        this.readImg.display()
    }
}

function test() {
    const proxy = new ProxyImg('1.png')
    proxy.display()
}

console.log('----------------代理模式-------------------')
test()